
<!DOCTYPE HTML>
<html lang="zh-hans" >
    <head>
        <meta charset="UTF-8">
        <meta content="text/html; charset=utf-8" http-equiv="Content-Type">
        <title>TypeScript 1.4 · TypeScript Handbook</title>
        <meta http-equiv="X-UA-Compatible" content="IE=edge" />
        <meta name="description" content="">
        <meta name="generator" content="GitBook 3.2.3">
        <meta name="author" content="Patrick Zhong">
        
        
    
    <link rel="stylesheet" href="../../gitbook/style.css">

    
            
                
                <link rel="stylesheet" href="../../gitbook/gitbook-plugin-highlight/website.css">
                
            
                
                <link rel="stylesheet" href="../../gitbook/gitbook-plugin-search/search.css">
                
            
                
                <link rel="stylesheet" href="../../gitbook/gitbook-plugin-fontsettings/website.css">
                
            
        

    

    
        
    
        
    
        
    
        
    
        
    
        
    

        
    
    
    <meta name="HandheldFriendly" content="true"/>
    <meta name="viewport" content="width=device-width, initial-scale=1, user-scalable=no">
    <meta name="apple-mobile-web-app-capable" content="yes">
    <meta name="apple-mobile-web-app-status-bar-style" content="black">
    <link rel="apple-touch-icon-precomposed" sizes="152x152" href="../../gitbook/images/apple-touch-icon-precomposed-152.png">
    <link rel="shortcut icon" href="../../gitbook/images/favicon.ico" type="image/x-icon">

    
    <link rel="next" href="TypeScript 1.3.html" />
    
    
    <link rel="prev" href="TypeScript 1.5.html" />
    

    </head>
    <body>
        
<div class="book">
    <div class="book-summary">
        
            
<div id="book-search-input" role="search">
    <input type="text" placeholder="输入并搜索" />
</div>

            
                <nav role="navigation">
                


<ul class="summary">
    
    

    

    
        
        
    
        <li class="chapter " data-level="1.1" data-path="../../">
            
                <a href="../../">
            
                    
                    Introduction
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.2" data-path="../handbook/tutorials/">
            
                <a href="../handbook/tutorials/">
            
                    
                    快速上手
            
                </a>
            

            
            <ul class="articles">
                
    
        <li class="chapter " data-level="1.2.1" data-path="../handbook/tutorials/TypeScript in 5 minutes.html">
            
                <a href="../handbook/tutorials/TypeScript in 5 minutes.html">
            
                    
                    5分钟了解TypeScript
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.2.2" data-path="../handbook/tutorials/ASP.NET Core.html">
            
                <a href="../handbook/tutorials/ASP.NET Core.html">
            
                    
                    ASP.NET Core
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.2.3" data-path="../handbook/tutorials/ASP.NET 4.html">
            
                <a href="../handbook/tutorials/ASP.NET 4.html">
            
                    
                    ASP.NET 4
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.2.4" data-path="../handbook/tutorials/Gulp.html">
            
                <a href="../handbook/tutorials/Gulp.html">
            
                    
                    Gulp
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.2.5" data-path="../handbook/tutorials/Knockout.html">
            
                <a href="../handbook/tutorials/Knockout.html">
            
                    
                    Knockout.js
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.2.6" data-path="../handbook/tutorials/React & Webpack.html">
            
                <a href="../handbook/tutorials/React & Webpack.html">
            
                    
                    React与webpack
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.2.7" data-path="../handbook/tutorials/React.html">
            
                <a href="../handbook/tutorials/React.html">
            
                    
                    React
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.2.8" data-path="../handbook/tutorials/Angular 2.html">
            
                <a href="../handbook/tutorials/Angular 2.html">
            
                    
                    Angular 2
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.2.9" data-path="../handbook/tutorials/Migrating from JavaScript.html">
            
                <a href="../handbook/tutorials/Migrating from JavaScript.html">
            
                    
                    从JavaScript迁移到TypeScript
            
                </a>
            

            
        </li>
    

            </ul>
            
        </li>
    
        <li class="chapter " data-level="1.3" data-path="../handbook/">
            
                <a href="../handbook/">
            
                    
                    手册
            
                </a>
            

            
            <ul class="articles">
                
    
        <li class="chapter " data-level="1.3.1" data-path="../handbook/Basic Types.html">
            
                <a href="../handbook/Basic Types.html">
            
                    
                    基础类型
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.3.2" data-path="../handbook/Variable Declarations.html">
            
                <a href="../handbook/Variable Declarations.html">
            
                    
                    变量声明
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.3.3" data-path="../handbook/Interfaces.html">
            
                <a href="../handbook/Interfaces.html">
            
                    
                    接口
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.3.4" data-path="../handbook/Classes.html">
            
                <a href="../handbook/Classes.html">
            
                    
                    类
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.3.5" data-path="../handbook/Functions.html">
            
                <a href="../handbook/Functions.html">
            
                    
                    函数
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.3.6" data-path="../handbook/Generics.html">
            
                <a href="../handbook/Generics.html">
            
                    
                    泛型
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.3.7" data-path="../handbook/Enums.html">
            
                <a href="../handbook/Enums.html">
            
                    
                    枚举
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.3.8" data-path="../handbook/Type Inference.html">
            
                <a href="../handbook/Type Inference.html">
            
                    
                    类型推论
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.3.9" data-path="../handbook/Type Compatibility.html">
            
                <a href="../handbook/Type Compatibility.html">
            
                    
                    类型兼容性
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.3.10" data-path="../handbook/Advanced Types.html">
            
                <a href="../handbook/Advanced Types.html">
            
                    
                    高级类型
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.3.11" data-path="../handbook/Utilit Types.md">
            
                <span>
            
                    
                    实用工具类型
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.3.12" data-path="../handbook/Symbols.html">
            
                <a href="../handbook/Symbols.html">
            
                    
                    Symbols
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.3.13" data-path="../handbook/Iterators and Generators.html">
            
                <a href="../handbook/Iterators and Generators.html">
            
                    
                    Iterators 和 Generators
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.3.14" data-path="../handbook/Modules.html">
            
                <a href="../handbook/Modules.html">
            
                    
                    模块
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.3.15" data-path="../handbook/Namespaces.html">
            
                <a href="../handbook/Namespaces.html">
            
                    
                    命名空间
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.3.16" data-path="../handbook/Namespaces and Modules.html">
            
                <a href="../handbook/Namespaces and Modules.html">
            
                    
                    命名空间和模块
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.3.17" data-path="../handbook/Module Resolution.html">
            
                <a href="../handbook/Module Resolution.html">
            
                    
                    模块解析
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.3.18" data-path="../handbook/Declaration Merging.html">
            
                <a href="../handbook/Declaration Merging.html">
            
                    
                    声明合并
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.3.19" data-path="../handbook/Writing Definition Files.html">
            
                <a href="../handbook/Writing Definition Files.html">
            
                    
                    书写.d.ts文件
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.3.20" data-path="../handbook/JSX.html">
            
                <a href="../handbook/JSX.html">
            
                    
                    JSX
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.3.21" data-path="../handbook/Decorators.html">
            
                <a href="../handbook/Decorators.html">
            
                    
                    Decorators
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.3.22" data-path="../handbook/Mixins.html">
            
                <a href="../handbook/Mixins.html">
            
                    
                    混入
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.3.23" data-path="../handbook/Triple-Slash Directives.html">
            
                <a href="../handbook/Triple-Slash Directives.html">
            
                    
                    三斜线指令
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.3.24" data-path="../handbook/Type Checking JavaScript Files.html">
            
                <a href="../handbook/Type Checking JavaScript Files.html">
            
                    
                    JavaScript文件里的类型检查
            
                </a>
            

            
        </li>
    

            </ul>
            
        </li>
    
        <li class="chapter " data-level="1.4" data-path="../handbook/declaration files/Introduction.html">
            
                <a href="../handbook/declaration files/Introduction.html">
            
                    
                    如何书写声明文件
            
                </a>
            

            
            <ul class="articles">
                
    
        <li class="chapter " data-level="1.4.1" data-path="../handbook/declaration files/Library Structures.html">
            
                <a href="../handbook/declaration files/Library Structures.html">
            
                    
                    结构
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.4.2" data-path="../handbook/declaration files/Do's and Don'ts.html">
            
                <a href="../handbook/declaration files/Do's and Don'ts.html">
            
                    
                    规范
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.4.3" data-path="../handbook/declaration files/By Example.html">
            
                <a href="../handbook/declaration files/By Example.html">
            
                    
                    举例
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.4.4" data-path="../handbook/declaration files/Deep Dive.html">
            
                <a href="../handbook/declaration files/Deep Dive.html">
            
                    
                    深入
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.4.5" data-path="../handbook/declaration files/Publishing.html">
            
                <a href="../handbook/declaration files/Publishing.html">
            
                    
                    发布
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.4.6" data-path="../handbook/declaration files/Consumption.html">
            
                <a href="../handbook/declaration files/Consumption.html">
            
                    
                    使用
            
                </a>
            

            
        </li>
    

            </ul>
            
        </li>
    
        <li class="chapter " data-level="1.5" data-path="../handbook/tsconfig.json.html">
            
                <a href="../handbook/tsconfig.json.html">
            
                    
                    工程配置
            
                </a>
            

            
            <ul class="articles">
                
    
        <li class="chapter " data-level="1.5.1" data-path="../handbook/tsconfig.json.html">
            
                <a href="../handbook/tsconfig.json.html">
            
                    
                    tsconfig.json
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.5.2" data-path="../handbook/Project References.html">
            
                <a href="../handbook/Project References.html">
            
                    
                    工程引用
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.5.3" data-path="../handbook/Typings for NPM Packages.html">
            
                <a href="../handbook/Typings for NPM Packages.html">
            
                    
                    NPM包的类型
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.5.4" data-path="../handbook/Compiler Options.html">
            
                <a href="../handbook/Compiler Options.html">
            
                    
                    编译选项
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.5.5" data-path="../handbook/Configuring Watch.html">
            
                <a href="../handbook/Configuring Watch.html">
            
                    
                    配置 Watch
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.5.6" data-path="../handbook/Compiler Options in MSBuild.html">
            
                <a href="../handbook/Compiler Options in MSBuild.html">
            
                    
                    在MSBuild里使用编译选项
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.5.7" data-path="../handbook/Integrating with Build Tools.html">
            
                <a href="../handbook/Integrating with Build Tools.html">
            
                    
                    与其它构建工具整合
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.5.8" data-path="../handbook/Nightly Builds.html">
            
                <a href="../handbook/Nightly Builds.html">
            
                    
                    使用TypeScript的每日构建版本
            
                </a>
            

            
        </li>
    

            </ul>
            
        </li>
    
        <li class="chapter " data-level="1.6" data-path="../wiki/">
            
                <a href="../wiki/">
            
                    
                    Wiki
            
                </a>
            

            
            <ul class="articles">
                
    
        <li class="chapter " data-level="1.6.1" data-path="../wiki/this-in-TypeScript.html">
            
                <a href="../wiki/this-in-TypeScript.html">
            
                    
                    TypeScript里的this
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.6.2" data-path="../wiki/coding_guidelines.html">
            
                <a href="../wiki/coding_guidelines.html">
            
                    
                    编码规范
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.6.3" data-path="../wiki/Common Errors.html">
            
                <a href="../wiki/Common Errors.html">
            
                    
                    常见编译错误
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.6.4" data-path="../wiki/TypeScript-Editor-Support.html">
            
                <a href="../wiki/TypeScript-Editor-Support.html">
            
                    
                    支持TypeScript的编辑器
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.6.5" data-path="../wiki/Using-TypeScript-With-ASP.NET-5.html">
            
                <a href="../wiki/Using-TypeScript-With-ASP.NET-5.html">
            
                    
                    结合ASP.NET v5使用TypeScript
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.6.6" data-path="../wiki/Architectural-Overview.html">
            
                <a href="../wiki/Architectural-Overview.html">
            
                    
                    架构概述
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.6.7" data-path="../wiki/Roadmap.html">
            
                <a href="../wiki/Roadmap.html">
            
                    
                    发展路线图
            
                </a>
            

            
        </li>
    

            </ul>
            
        </li>
    
        <li class="chapter " data-level="1.7" data-path="./">
            
                <a href="./">
            
                    
                    新增功能
            
                </a>
            

            
            <ul class="articles">
                
    
        <li class="chapter " data-level="1.7.1" data-path="TypeScript 3.1.html">
            
                <a href="TypeScript 3.1.html">
            
                    
                    TypeScript 3.1
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.7.2" data-path="TypeScript 3.0.html">
            
                <a href="TypeScript 3.0.html">
            
                    
                    TypeScript 3.0
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.7.3" data-path="TypeScript 2.9.html">
            
                <a href="TypeScript 2.9.html">
            
                    
                    TypeScript 2.9
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.7.4" data-path="TypeScript 2.8.html">
            
                <a href="TypeScript 2.8.html">
            
                    
                    TypeScript 2.8
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.7.5" data-path="TypeScript 2.7.html">
            
                <a href="TypeScript 2.7.html">
            
                    
                    TypeScript 2.7
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.7.6" data-path="TypeScript 2.6.html">
            
                <a href="TypeScript 2.6.html">
            
                    
                    TypeScript 2.6
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.7.7" data-path="TypeScript 2.5.html">
            
                <a href="TypeScript 2.5.html">
            
                    
                    TypeScript 2.5
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.7.8" data-path="TypeScript 2.4.html">
            
                <a href="TypeScript 2.4.html">
            
                    
                    TypeScript 2.4
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.7.9" data-path="TypeScript 2.3.html">
            
                <a href="TypeScript 2.3.html">
            
                    
                    TypeScript 2.3
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.7.10" data-path="TypeScript 2.2.html">
            
                <a href="TypeScript 2.2.html">
            
                    
                    TypeScript 2.2
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.7.11" data-path="TypeScript 2.1.html">
            
                <a href="TypeScript 2.1.html">
            
                    
                    TypeScript 2.1
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.7.12" data-path="TypeScript 2.0.html">
            
                <a href="TypeScript 2.0.html">
            
                    
                    TypeScript 2.0
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.7.13" data-path="TypeScript 1.8.html">
            
                <a href="TypeScript 1.8.html">
            
                    
                    TypeScript 1.8
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.7.14" data-path="TypeScript 1.7.html">
            
                <a href="TypeScript 1.7.html">
            
                    
                    TypeScript 1.7
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.7.15" data-path="TypeScript 1.6.html">
            
                <a href="TypeScript 1.6.html">
            
                    
                    TypeScript 1.6
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.7.16" data-path="TypeScript 1.5.html">
            
                <a href="TypeScript 1.5.html">
            
                    
                    TypeScript 1.5
            
                </a>
            

            
        </li>
    
        <li class="chapter active" data-level="1.7.17" data-path="TypeScript 1.4.html">
            
                <a href="TypeScript 1.4.html">
            
                    
                    TypeScript 1.4
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.7.18" data-path="TypeScript 1.3.html">
            
                <a href="TypeScript 1.3.html">
            
                    
                    TypeScript 1.3
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.7.19" data-path="TypeScript 1.1.html">
            
                <a href="TypeScript 1.1.html">
            
                    
                    TypeScript 1.1
            
                </a>
            

            
        </li>
    

            </ul>
            
        </li>
    
        <li class="chapter " data-level="1.8" data-path="../breaking-changes/breaking-changes.html">
            
                <a href="../breaking-changes/breaking-changes.html">
            
                    
                    Breaking Changes
            
                </a>
            

            
            <ul class="articles">
                
    
        <li class="chapter " data-level="1.8.1" data-path="../breaking-changes/TypeScript 2.4.html">
            
                <a href="../breaking-changes/TypeScript 2.4.html">
            
                    
                    TypeScript 2.4
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.8.2" data-path="../breaking-changes/TypeScript 2.3.html">
            
                <a href="../breaking-changes/TypeScript 2.3.html">
            
                    
                    TypeScript 2.3
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.8.3" data-path="../breaking-changes/TypeScript 2.2.html">
            
                <a href="../breaking-changes/TypeScript 2.2.html">
            
                    
                    TypeScript 2.2
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.8.4" data-path="../breaking-changes/TypeScript 2.1.html">
            
                <a href="../breaking-changes/TypeScript 2.1.html">
            
                    
                    TypeScript 2.1
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.8.5" data-path="../breaking-changes/TypeScript 2.0.html">
            
                <a href="../breaking-changes/TypeScript 2.0.html">
            
                    
                    TypeScript 2.0
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.8.6" data-path="../breaking-changes/TypeScript 1.8.html">
            
                <a href="../breaking-changes/TypeScript 1.8.html">
            
                    
                    TypeScript 1.8
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.8.7" data-path="../breaking-changes/TypeScript 1.7.html">
            
                <a href="../breaking-changes/TypeScript 1.7.html">
            
                    
                    TypeScript 1.7
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.8.8" data-path="../breaking-changes/TypeScript 1.6.html">
            
                <a href="../breaking-changes/TypeScript 1.6.html">
            
                    
                    TypeScript 1.6
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.8.9" data-path="../breaking-changes/TypeScript 1.5.html">
            
                <a href="../breaking-changes/TypeScript 1.5.html">
            
                    
                    TypeScript 1.5
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.8.10" data-path="../breaking-changes/TypeScript 1.4.html">
            
                <a href="../breaking-changes/TypeScript 1.4.html">
            
                    
                    TypeScript 1.4
            
                </a>
            

            
        </li>
    

            </ul>
            
        </li>
    

    

    <li class="divider"></li>

    <li>
        <a href="https://www.gitbook.com" target="blank" class="gitbook-link">
            本书使用 GitBook 发布
        </a>
    </li>
</ul>


                </nav>
            
        
    </div>

    <div class="book-body">
        
            <div class="body-inner">
                
                    

<div class="book-header" role="navigation">
    

    <!-- Title -->
    <h1>
        <i class="fa fa-circle-o-notch fa-spin"></i>
        <a href="../.." >TypeScript 1.4</a>
    </h1>
</div>




                    <div class="page-wrapper" tabindex="-1" role="main">
                        <div class="page-inner">
                            
<div id="book-search-results">
    <div class="search-noresults">
    
                                <section class="normal markdown-section">
                                
                                <h1 id="typescript-14">TypeScript 1.4</h1>
<h2 id="&#x8054;&#x5408;&#x7C7B;&#x578B;">&#x8054;&#x5408;&#x7C7B;&#x578B;</h2>
<h3 id="&#x6982;&#x8FF0;">&#x6982;&#x8FF0;</h3>
<p>&#x8054;&#x5408;&#x7C7B;&#x578B;&#x6709;&#x52A9;&#x4E8E;&#x8868;&#x793A;&#x4E00;&#x4E2A;&#x503C;&#x7684;&#x7C7B;&#x578B;&#x53EF;&#x4EE5;&#x662F;&#x591A;&#x79CD;&#x7C7B;&#x578B;&#x4E4B;&#x4E00;&#x7684;&#x60C5;&#x51B5;&#x3002;&#x6BD4;&#x5982;&#xFF0C;&#x6709;&#x4E00;&#x4E2A;API&#x63A5;&#x547D;&#x4EE4;&#x884C;&#x4F20;&#x5165;<code>string</code>&#x7C7B;&#x578B;&#xFF0C;<code>string[]</code>&#x7C7B;&#x578B;&#x6216;&#x8005;&#x662F;&#x4E00;&#x4E2A;&#x8FD4;&#x56DE;<code>string</code>&#x7684;&#x51FD;&#x6570;&#x3002;&#x4F60;&#x5C31;&#x53EF;&#x4EE5;&#x8FD9;&#x6837;&#x5199;&#xFF1A;</p>
<pre><code class="lang-ts"><span class="hljs-keyword">interface</span> RunOptions {
   program: <span class="hljs-built_in">string</span>;
   commandline: <span class="hljs-built_in">string</span>[]|<span class="hljs-built_in">string</span>|(() =&gt; <span class="hljs-built_in">string</span>);
}
</code></pre>
<p>&#x7ED9;&#x8054;&#x5408;&#x7C7B;&#x578B;&#x8D4B;&#x503C;&#x4E5F;&#x5F88;&#x76F4;&#x89C2; -- &#x53EA;&#x8981;&#x8FD9;&#x4E2A;&#x503C;&#x80FD;&#x6EE1;&#x8DB3;&#x8054;&#x5408;&#x7C7B;&#x578B;&#x4E2D;&#x4EFB;&#x610F;&#x4E00;&#x4E2A;&#x7C7B;&#x578B;&#x90A3;&#x4E48;&#x5C31;&#x53EF;&#x4EE5;&#x8D4B;&#x503C;&#x7ED9;&#x8FD9;&#x4E2A;&#x8054;&#x5408;&#x7C7B;&#x578B;&#xFF1A;</p>
<pre><code class="lang-ts"><span class="hljs-keyword">var</span> opts: RunOptions = <span class="hljs-comment">/* ... */</span>;
opts.commandline = <span class="hljs-string">&apos;-hello world&apos;</span>; <span class="hljs-comment">// OK</span>
opts.commandline = [<span class="hljs-string">&apos;-hello&apos;</span>, <span class="hljs-string">&apos;world&apos;</span>]; <span class="hljs-comment">// OK</span>
opts.commandline = [<span class="hljs-number">42</span>]; <span class="hljs-comment">// Error, &#x6570;&#x5B57;&#x4E0D;&#x662F;&#x5B57;&#x7B26;&#x4E32;&#x6216;&#x5B57;&#x7B26;&#x4E32;&#x6570;&#x7EC4;</span>
</code></pre>
<p>&#x5F53;&#x8BFB;&#x53D6;&#x8054;&#x5408;&#x7C7B;&#x578B;&#x65F6;&#xFF0C;&#x4F60;&#x53EF;&#x4EE5;&#x8BBF;&#x95EE;&#x7C7B;&#x578B;&#x5171;&#x6709;&#x7684;&#x5C5E;&#x6027;&#xFF1A;</p>
<pre><code class="lang-ts"><span class="hljs-keyword">if</span>(opts.length === <span class="hljs-number">0</span>) { <span class="hljs-comment">// OK, string&#x548C;string[]&#x90FD;&#x6709;&apos;length&apos;&#x5C5E;&#x6027;</span>
  <span class="hljs-built_in">console</span>.log(<span class="hljs-string">&quot;it&apos;s empty&quot;</span>);
}
</code></pre>
<p>&#x4F7F;&#x7528;&#x7C7B;&#x578B;&#x4FDD;&#x62A4;&#xFF0C;&#x4F60;&#x53EF;&#x4EE5;&#x8F7B;&#x677E;&#x5730;&#x4F7F;&#x7528;&#x8054;&#x5408;&#x7C7B;&#x578B;&#xFF1A;</p>
<pre><code class="lang-ts"><span class="hljs-function"><span class="hljs-keyword">function</span> <span class="hljs-title">formatCommandline</span>(<span class="hljs-params">c: <span class="hljs-built_in">string</span>|<span class="hljs-built_in">string</span>[]</span>) </span>{
    <span class="hljs-keyword">if</span>(<span class="hljs-keyword">typeof</span> c === <span class="hljs-string">&apos;string&apos;</span>) {
        <span class="hljs-keyword">return</span> c.trim();
    } <span class="hljs-keyword">else</span> {
        <span class="hljs-keyword">return</span> c.join(<span class="hljs-string">&apos; &apos;</span>);
    }
}
</code></pre>
<h3 id="&#x4E25;&#x683C;&#x7684;&#x6CDB;&#x578B;">&#x4E25;&#x683C;&#x7684;&#x6CDB;&#x578B;</h3>
<p>&#x968F;&#x7740;&#x8054;&#x5408;&#x7C7B;&#x578B;&#x53EF;&#x4EE5;&#x8868;&#x793A;&#x6709;&#x5F88;&#x591A;&#x7C7B;&#x578B;&#x7684;&#x573A;&#x666F;&#xFF0C;&#x6211;&#x4EEC;&#x51B3;&#x5B9A;&#x53BB;&#x6539;&#x8FDB;&#x6CDB;&#x578B;&#x8C03;&#x7528;&#x7684;&#x89C4;&#x8303;&#x6027;&#x3002;&#x4E4B;&#x524D;&#xFF0C;&#x8FD9;&#x6BB5;&#x4EE3;&#x7801;&#x7F16;&#x8BD1;&#x4E0D;&#x4F1A;&#x62A5;&#x9519;&#xFF08;&#x51FA;&#x4E4E;&#x610F;&#x6599;&#xFF09;&#xFF1A;</p>
<pre><code class="lang-ts"><span class="hljs-function"><span class="hljs-keyword">function</span> <span class="hljs-title">equal</span>&lt;<span class="hljs-title">T</span>&gt;(<span class="hljs-params">lhs: T, rhs: T</span>): <span class="hljs-title">boolean</span> </span>{
  <span class="hljs-keyword">return</span> lhs === rhs;
}

<span class="hljs-comment">// &#x4E4B;&#x524D;&#x6CA1;&#x6709;&#x9519;&#x8BEF;</span>
<span class="hljs-comment">// &#x73B0;&#x5728;&#x4F1A;&#x62A5;&#x9519;&#xFF1A;&#x5728;string&#x548C;number&#x4E4B;&#x524D;&#x6CA1;&#x6709;&#x6700;&#x4F73;&#x7684;&#x57FA;&#x672C;&#x7C7B;&#x578B;</span>
<span class="hljs-keyword">var</span> e = equal(<span class="hljs-number">42</span>, <span class="hljs-string">&apos;hello&apos;</span>);
</code></pre>
<p>&#x901A;&#x8FC7;&#x8054;&#x5408;&#x7C7B;&#x578B;&#xFF0C;&#x4F60;&#x53EF;&#x4EE5;&#x6307;&#x5B9A;&#x4F60;&#x60F3;&#x8981;&#x7684;&#x884C;&#x4E3A;&#xFF0C;&#x5728;&#x51FD;&#x6570;&#x5B9A;&#x4E49;&#x65F6;&#x6216;&#x5728;&#x8C03;&#x7528;&#x7684;&#x65F6;&#x5019;&#xFF1A;</p>
<pre><code class="lang-ts"><span class="hljs-comment">// &apos;choose&apos; function where types must match</span>
<span class="hljs-function"><span class="hljs-keyword">function</span> <span class="hljs-title">choose1</span>&lt;<span class="hljs-title">T</span>&gt;(<span class="hljs-params">a: T, b: T</span>): <span class="hljs-title">T</span> </span>{ <span class="hljs-keyword">return</span> <span class="hljs-built_in">Math</span>.random() &gt; <span class="hljs-number">0.5</span> ? a : b }
<span class="hljs-keyword">var</span> a = choose1(<span class="hljs-string">&apos;hello&apos;</span>, <span class="hljs-number">42</span>); <span class="hljs-comment">// Error</span>
<span class="hljs-keyword">var</span> b = choose1&lt;<span class="hljs-built_in">string</span>|<span class="hljs-built_in">number</span>&gt;(<span class="hljs-string">&apos;hello&apos;</span>, <span class="hljs-number">42</span>); <span class="hljs-comment">// OK</span>

<span class="hljs-comment">// &apos;choose&apos; function where types need not match</span>
<span class="hljs-function"><span class="hljs-keyword">function</span> <span class="hljs-title">choose2</span>&lt;<span class="hljs-title">T</span>, <span class="hljs-title">U</span>&gt;(<span class="hljs-params">a: T, b: U</span>): <span class="hljs-title">T</span>|<span class="hljs-title">U</span> </span>{ <span class="hljs-keyword">return</span> <span class="hljs-built_in">Math</span>.random() &gt; <span class="hljs-number">0.5</span> ? a : b }
<span class="hljs-keyword">var</span> c = choose2(<span class="hljs-string">&apos;bar&apos;</span>, <span class="hljs-string">&apos;foo&apos;</span>); <span class="hljs-comment">// OK, c: string</span>
<span class="hljs-keyword">var</span> d = choose2(<span class="hljs-string">&apos;hello&apos;</span>, <span class="hljs-number">42</span>); <span class="hljs-comment">// OK, d: string|number</span>
</code></pre>
<h3 id="&#x66F4;&#x597D;&#x7684;&#x7C7B;&#x578B;&#x63A8;&#x65AD;">&#x66F4;&#x597D;&#x7684;&#x7C7B;&#x578B;&#x63A8;&#x65AD;</h3>
<p>&#x5F53;&#x4E00;&#x4E2A;&#x96C6;&#x5408;&#x91CC;&#x6709;&#x591A;&#x79CD;&#x7C7B;&#x578B;&#x7684;&#x503C;&#x65F6;&#xFF0C;&#x8054;&#x5408;&#x7C7B;&#x578B;&#x4F1A;&#x4E3A;&#x6570;&#x7EC4;&#x6216;&#x5176;&#x5B83;&#x5730;&#x65B9;&#x63D0;&#x4F9B;&#x66F4;&#x597D;&#x7684;&#x7C7B;&#x578B;&#x63A8;&#x65AD;&#xFF1A;</p>
<pre><code class="lang-ts"><span class="hljs-keyword">var</span> x = [<span class="hljs-number">1</span>, <span class="hljs-string">&apos;hello&apos;</span>]; <span class="hljs-comment">// x: Array&lt;string|number&gt;</span>
x[<span class="hljs-number">0</span>] = <span class="hljs-string">&apos;world&apos;</span>; <span class="hljs-comment">// OK</span>
x[<span class="hljs-number">0</span>] = <span class="hljs-literal">false</span>; <span class="hljs-comment">// Error, boolean is not string or number</span>
</code></pre>
<h2 id="let-&#x58F0;&#x660E;"><code>let</code> &#x58F0;&#x660E;</h2>
<p>&#x5728;JavaScript&#x91CC;&#xFF0C;<code>var</code>&#x58F0;&#x660E;&#x4F1A;&#x88AB;&#x201C;&#x63D0;&#x5347;&#x201D;&#x5230;&#x6240;&#x5728;&#x4F5C;&#x7528;&#x57DF;&#x7684;&#x9876;&#x7AEF;&#x3002;&#x8FD9;&#x53EF;&#x80FD;&#x4F1A;&#x5F15;&#x53D1;&#x4E00;&#x4E9B;&#x8BA9;&#x4EBA;&#x4E0D;&#x89E3;&#x7684;bugs&#xFF1A;</p>
<pre><code class="lang-ts"><span class="hljs-built_in">console</span>.log(x); <span class="hljs-comment">// meant to write &apos;y&apos; here</span>
<span class="hljs-comment">/* later in the same block */</span>
<span class="hljs-keyword">var</span> x = <span class="hljs-string">&apos;hello&apos;</span>;
</code></pre>
<p>TypeScript&#x5DF2;&#x7ECF;&#x652F;&#x6301;&#x65B0;&#x7684;ES6&#x7684;&#x5173;&#x952E;&#x5B57;<code>let</code>&#xFF0C;&#x58F0;&#x660E;&#x4E00;&#x4E2A;&#x5757;&#x7EA7;&#x4F5C;&#x7528;&#x57DF;&#x7684;&#x53D8;&#x91CF;&#x3002;&#x4E00;&#x4E2A;<code>let</code>&#x53D8;&#x91CF;&#x53EA;&#x80FD;&#x5728;&#x58F0;&#x660E;&#x4E4B;&#x540E;&#x7684;&#x4F4D;&#x7F6E;&#x88AB;&#x5F15;&#x7528;&#xFF0C;&#x5E76;&#x4E14;&#x4F5C;&#x7528;&#x57DF;&#x4E3A;&#x58F0;&#x660E;&#x5B83;&#x7684;&#x5757;&#x91CC;&#xFF1A;</p>
<pre><code class="lang-ts"><span class="hljs-keyword">if</span>(foo) {
    <span class="hljs-built_in">console</span>.log(x); <span class="hljs-comment">// Error, cannot refer to x before its declaration</span>
    <span class="hljs-keyword">let</span> x = <span class="hljs-string">&apos;hello&apos;</span>;
} <span class="hljs-keyword">else</span> {
    <span class="hljs-built_in">console</span>.log(x); <span class="hljs-comment">// Error, x is not declared in this block</span>
}
</code></pre>
<p><code>let</code>&#x53EA;&#x5728;&#x8BBE;&#x7F6E;&#x76EE;&#x6807;&#x4E3A;ECMAScript 6 &#xFF08;<code>--target ES6</code>&#xFF09;&#x65F6;&#x751F;&#x6548;&#x3002;</p>
<h2 id="const-&#x58F0;&#x660E;"><code>const</code> &#x58F0;&#x660E;</h2>
<p>&#x53E6;&#x4E00;&#x4E2A;TypeScript&#x652F;&#x6301;&#x7684;ES6&#x91CC;&#x65B0;&#x51FA;&#x73B0;&#x7684;&#x58F0;&#x660E;&#x7C7B;&#x578B;&#x662F;<code>const</code>&#x3002;&#x4E0D;&#x80FD;&#x7ED9;&#x4E00;&#x4E2A;<code>const</code>&#x7C7B;&#x578B;&#x53D8;&#x91CF;&#x8D4B;&#x503C;&#xFF0C;&#x53EA;&#x80FD;&#x5728;&#x58F0;&#x660E;&#x7684;&#x65F6;&#x5019;&#x521D;&#x59CB;&#x5316;&#x3002;&#x8FD9;&#x5BF9;&#x4E8E;&#x90A3;&#x4E9B;&#x5728;&#x521D;&#x59CB;&#x5316;&#x4E4B;&#x540E;&#x5C31;&#x4E0D;&#x60F3;&#x53BB;&#x6539;&#x53D8;&#x5B83;&#x7684;&#x503C;&#x7684;&#x60C5;&#x51B5;&#x4E0B;&#x662F;&#x5F88;&#x6709;&#x5E2E;&#x52A9;&#x7684;&#xFF1A;</p>
<pre><code class="lang-ts"><span class="hljs-keyword">const</span> halfPi = <span class="hljs-built_in">Math</span>.PI / <span class="hljs-number">2</span>;
halfPi = <span class="hljs-number">2</span>; <span class="hljs-comment">// Error, can&apos;t assign to a `const`</span>
</code></pre>
<p><code>const</code>&#x53EA;&#x5728;&#x8BBE;&#x7F6E;&#x76EE;&#x6807;&#x4E3A;ECMAScript 6 &#xFF08;<code>--target ES6</code>&#xFF09;&#x65F6;&#x751F;&#x6548;&#x3002;</p>
<h2 id="&#x6A21;&#x7248;&#x5B57;&#x7B26;&#x4E32;">&#x6A21;&#x7248;&#x5B57;&#x7B26;&#x4E32;</h2>
<p>TypeScript&#x73B0;&#x5DF2;&#x652F;&#x6301;ES6&#x6A21;&#x5757;&#x5B57;&#x7B26;&#x4E32;&#x3002;&#x901A;&#x8FC7;&#x5B83;&#x53EF;&#x4EE5;&#x65B9;&#x4FBF;&#x5730;&#x5728;&#x5B57;&#x7B26;&#x4E32;&#x4E2D;&#x5D4C;&#x5165;&#x4EFB;&#x4F55;&#x8868;&#x8FBE;&#x5F0F;&#xFF1A;</p>
<pre><code class="lang-ts"><span class="hljs-keyword">var</span> name = <span class="hljs-string">&quot;TypeScript&quot;</span>;
<span class="hljs-keyword">var</span> greeting  = <span class="hljs-string">`Hello, <span class="hljs-subst">${name}</span>! Your name has <span class="hljs-subst">${name.length}</span> characters`</span>;
</code></pre>
<p>&#x5F53;&#x7F16;&#x8BD1;&#x76EE;&#x6807;&#x4E3A;ES6&#x4E4B;&#x524D;&#x7684;&#x7248;&#x672C;&#x65F6;&#xFF0C;&#x8FD9;&#x4E2A;&#x5B57;&#x7B26;&#x4E32;&#x88AB;&#x5206;&#x89E3;&#x4E3A;&#xFF1A;</p>
<pre><code class="lang-js"><span class="hljs-keyword">var</span> name = <span class="hljs-string">&quot;TypeScript!&quot;</span>;
<span class="hljs-keyword">var</span> greeting = <span class="hljs-string">&quot;Hello, &quot;</span> + name + <span class="hljs-string">&quot;! Your name has &quot;</span> + name.length + <span class="hljs-string">&quot; characters&quot;</span>;
</code></pre>
<h2 id="&#x7C7B;&#x578B;&#x5B88;&#x62A4;">&#x7C7B;&#x578B;&#x5B88;&#x62A4;</h2>
<p>JavaScript&#x5E38;&#x7528;&#x6A21;&#x5F0F;&#x4E4B;&#x4E00;&#x662F;&#x5728;&#x8FD0;&#x884C;&#x65F6;&#x4F7F;&#x7528;<code>typeof</code>&#x6216;<code>instanceof</code>&#x68C0;&#x67E5;&#x8868;&#x8FBE;&#x5F0F;&#x7684;&#x7C7B;&#x578B;&#x3002; &#x5728;<code>if</code>&#x8BED;&#x53E5;&#x91CC;&#x4F7F;&#x7528;&#x5B83;&#x4EEC;&#x7684;&#x65F6;&#x5019;&#xFF0C;TypeScript&#x53EF;&#x4EE5;&#x8BC6;&#x522B;&#x51FA;&#x8FD9;&#x4E9B;&#x6761;&#x4EF6;&#x5E76;&#x4E14;&#x968F;&#x4E4B;&#x6539;&#x53D8;&#x7C7B;&#x578B;&#x63A8;&#x65AD;&#x7684;&#x7ED3;&#x679C;&#x3002;</p>
<p>&#x4F7F;&#x7528;<code>typeof</code>&#x6765;&#x68C0;&#x67E5;&#x4E00;&#x4E2A;&#x53D8;&#x91CF;&#xFF1A;</p>
<pre><code class="lang-ts"><span class="hljs-keyword">var</span> x: <span class="hljs-built_in">any</span> = <span class="hljs-comment">/* ... */</span>;
<span class="hljs-keyword">if</span>(<span class="hljs-keyword">typeof</span> x === <span class="hljs-string">&apos;string&apos;</span>) {
    <span class="hljs-built_in">console</span>.log(x.subtr(<span class="hljs-number">1</span>)); <span class="hljs-comment">// Error, &apos;subtr&apos; does not exist on &apos;string&apos;</span>
}
<span class="hljs-comment">// x is still any here</span>
x.unknown(); <span class="hljs-comment">// OK</span>
</code></pre>
<p>&#x7ED3;&#x5408;&#x8054;&#x5408;&#x7C7B;&#x578B;&#x4F7F;&#x7528;<code>typeof</code>&#x548C;<code>else</code>&#xFF1A;</p>
<pre><code class="lang-ts"><span class="hljs-keyword">var</span> x: <span class="hljs-built_in">string</span>|HTMLElement = <span class="hljs-comment">/* ... */</span>;
<span class="hljs-keyword">if</span>(<span class="hljs-keyword">typeof</span> x === <span class="hljs-string">&apos;string&apos;</span>) {
    <span class="hljs-comment">// x is string here, as shown above</span>
} <span class="hljs-keyword">else</span> {
    <span class="hljs-comment">// x is HTMLElement here</span>
    <span class="hljs-built_in">console</span>.log(x.innerHTML);
}
</code></pre>
<p>&#x7ED3;&#x5408;&#x7C7B;&#x548C;&#x8054;&#x5408;&#x7C7B;&#x578B;&#x4F7F;&#x7528;<code>instanceof</code>&#xFF1A;</p>
<pre><code class="lang-ts"><span class="hljs-keyword">class</span> Dog { woof() { } }
<span class="hljs-keyword">class</span> Cat { meow() { } }
<span class="hljs-keyword">var</span> pet: Dog|Cat = <span class="hljs-comment">/* ... */</span>;
<span class="hljs-keyword">if</span>(pet <span class="hljs-keyword">instanceof</span> Dog) {
    pet.woof(); <span class="hljs-comment">// OK</span>
} <span class="hljs-keyword">else</span> {
    pet.woof(); <span class="hljs-comment">// Error</span>
}
</code></pre>
<h2 id="&#x7C7B;&#x578B;&#x522B;&#x540D;">&#x7C7B;&#x578B;&#x522B;&#x540D;</h2>
<p>&#x4F60;&#x73B0;&#x5728;&#x53EF;&#x4EE5;&#x4F7F;&#x7528;<code>type</code>&#x5173;&#x952E;&#x5B57;&#x6765;&#x4E3A;&#x7C7B;&#x578B;&#x5B9A;&#x4E49;&#x4E00;&#x4E2A;&#x201C;&#x522B;&#x540D;&#x201D;&#xFF1A;</p>
<pre><code class="lang-ts"><span class="hljs-keyword">type</span> PrimitiveArray = <span class="hljs-built_in">Array</span>&lt;<span class="hljs-built_in">string</span>|<span class="hljs-built_in">number</span>|<span class="hljs-built_in">boolean</span>&gt;;
<span class="hljs-keyword">type</span> MyNumber = <span class="hljs-built_in">number</span>;
<span class="hljs-keyword">type</span> NgScope = ng.IScope;
<span class="hljs-keyword">type</span> Callback = () =&gt; <span class="hljs-built_in">void</span>;
</code></pre>
<p>&#x7C7B;&#x578B;&#x522B;&#x540D;&#x4E0E;&#x5176;&#x539F;&#x59CB;&#x7684;&#x7C7B;&#x578B;&#x5B8C;&#x5168;&#x4E00;&#x81F4;&#xFF1B;&#x5B83;&#x4EEC;&#x53EA;&#x662F;&#x7B80;&#x5355;&#x7684;&#x66FF;&#x4EE3;&#x540D;&#x3002;</p>
<h2 id="const-enum&#xFF08;&#x5B8C;&#x5168;&#x5D4C;&#x5165;&#x7684;&#x679A;&#x4E3E;&#xFF09;"><code>const enum</code>&#xFF08;&#x5B8C;&#x5168;&#x5D4C;&#x5165;&#x7684;&#x679A;&#x4E3E;&#xFF09;</h2>
<p>&#x679A;&#x4E3E;&#x5F88;&#x6709;&#x5E2E;&#x52A9;&#xFF0C;&#x4F46;&#x662F;&#x6709;&#x4E9B;&#x7A0B;&#x5E8F;&#x5B9E;&#x9645;&#x4E0A;&#x5E76;&#x4E0D;&#x9700;&#x8981;&#x5B83;&#x751F;&#x6210;&#x7684;&#x4EE3;&#x7801;&#x5E76;&#x4E14;&#x60F3;&#x8981;&#x5C06;&#x679A;&#x4E3E;&#x53D8;&#x91CF;&#x6240;&#x4EE3;&#x7801;&#x7684;&#x6570;&#x5B57;&#x503C;&#x76F4;&#x63A5;&#x66FF;&#x6362;&#x5230;&#x5BF9;&#x5E94;&#x4F4D;&#x7F6E;&#x4E0A;&#x3002;&#x65B0;&#x7684;<code>const enum</code>&#x58F0;&#x660E;&#x4E0E;&#x6B63;&#x5E38;&#x7684;<code>enum</code>&#x5728;&#x7C7B;&#x578B;&#x5B89;&#x5168;&#x65B9;&#x9762;&#x5177;&#x6709;&#x540C;&#x6837;&#x7684;&#x4F5C;&#x7528;&#xFF0C;&#x53EA;&#x662F;&#x5728;&#x7F16;&#x8BD1;&#x65F6;&#x4F1A;&#x6E05;&#x9664;&#x6389;&#x3002;</p>
<pre><code class="lang-ts"><span class="hljs-keyword">const</span> <span class="hljs-keyword">enum</span> Suit { Clubs, Diamonds, Hearts, Spades }
<span class="hljs-keyword">var</span> d = Suit.Diamonds;
</code></pre>
<p>Compiles to exactly:</p>
<pre><code class="lang-js"><span class="hljs-keyword">var</span> d = <span class="hljs-number">1</span>;
</code></pre>
<p>TypeScript&#x4E5F;&#x4F1A;&#x5728;&#x53EF;&#x80FD;&#x7684;&#x60C5;&#x51B5;&#x4E0B;&#x8BA1;&#x7B97;&#x679A;&#x4E3E;&#x503C;&#xFF1A;</p>
<pre><code class="lang-ts"><span class="hljs-keyword">enum</span> MyFlags {
  None = <span class="hljs-number">0</span>,
  Neat = <span class="hljs-number">1</span>,
  Cool = <span class="hljs-number">2</span>,
  Awesome = <span class="hljs-number">4</span>,
  Best = Neat | Cool | Awesome
}
<span class="hljs-keyword">var</span> b = MyFlags.Best; <span class="hljs-comment">// emits var b = 7;</span>
</code></pre>
<h2 id="noemitonerror-&#x547D;&#x4EE4;&#x884C;&#x9009;&#x9879;"><code>-noEmitOnError</code> &#x547D;&#x4EE4;&#x884C;&#x9009;&#x9879;</h2>
<p>TypeScript&#x7F16;&#x8BD1;&#x5668;&#x7684;&#x9ED8;&#x8BA4;&#x884C;&#x4E3A;&#x662F;&#x5F53;&#x5B58;&#x5728;&#x7C7B;&#x578B;&#x9519;&#x8BEF;&#xFF08;&#x6BD4;&#x5982;&#xFF0C;&#x5C06;<code>string</code>&#x7C7B;&#x578B;&#x8D4B;&#x503C;&#x7ED9;<code>number</code>&#x7C7B;&#x578B;&#xFF09;&#x65F6;&#x4ECD;&#x4F1A;&#x751F;&#x6210;.js&#x6587;&#x4EF6;&#x3002;&#x8FD9;&#x5728;&#x6784;&#x5EFA;&#x670D;&#x52A1;&#x5668;&#x4E0A;&#x6216;&#x662F;&#x5176;&#x5B83;&#x573A;&#x666F;&#x91CC;&#x53EF;&#x80FD;&#x4F1A;&#x662F;&#x4E0D;&#x60F3;&#x770B;&#x5230;&#x7684;&#x60C5;&#x51B5;&#xFF0C;&#x56E0;&#x4E3A;&#x5E0C;&#x671B;&#x5F97;&#x5230;&#x7684;&#x662F;&#x4E00;&#x6B21;&#x201C;&#x7EAF;&#x51C0;&#x201D;&#x7684;&#x6784;&#x5EFA;&#x3002;&#x65B0;&#x7684;<code>noEmitOnError</code>&#x6807;&#x8BB0;&#x53EF;&#x4EE5;&#x963B;&#x6B62;&#x5728;&#x7F16;&#x8BD1;&#x65F6;&#x9047;&#x5230;&#x9519;&#x8BEF;&#x7684;&#x60C5;&#x51B5;&#x4E0B;&#x7EE7;&#x7EED;&#x751F;&#x6210;.js&#x4EE3;&#x7801;&#x3002;</p>
<p>&#x5B83;&#x73B0;&#x5728;&#x662F;MSBuild&#x5DE5;&#x7A0B;&#x7684;&#x9ED8;&#x8BA4;&#x884C;&#x4E3A;&#xFF1B;&#x8FD9;&#x5141;&#x8BB8;MSBuild&#x6301;&#x7EED;&#x6784;&#x5EFA;&#x4EE5;&#x6211;&#x4EEC;&#x60F3;&#x8981;&#x7684;&#x884C;&#x4E3A;&#x8FDB;&#x884C;&#xFF0C;&#x8F93;&#x51FA;&#x6C38;&#x8FDC;&#x662F;&#x6765;&#x81EA;&#x7EAF;&#x51C0;&#x7684;&#x6784;&#x5EFA;&#x3002;</p>
<h2 id="amd-&#x6A21;&#x5757;&#x540D;">AMD &#x6A21;&#x5757;&#x540D;</h2>
<p>&#x9ED8;&#x8BA4;&#x60C5;&#x51B5;&#x4E0B;AMD&#x6A21;&#x5757;&#x4EE5;&#x533F;&#x540D;&#x5F62;&#x5F0F;&#x751F;&#x6210;&#x3002;&#x8FD9;&#x5728;&#x4F7F;&#x7528;&#x5176;&#x5B83;&#x5DE5;&#x5177;&#xFF08;&#x6BD4;&#x5982;&#xFF0C;r.js&#xFF09;&#x5904;&#x7406;&#x751F;&#x6210;&#x7684;&#x6A21;&#x5757;&#x7684;&#x65F6;&#x53EF;&#x80FD;&#x4F1A;&#x5E26;&#x6765;&#x9EBB;&#x70E6;&#x3002;</p>
<p>&#x65B0;&#x7684;<code>amd-module name</code>&#x6807;&#x7B7E;&#x5141;&#x8BB8;&#x7ED9;&#x7F16;&#x8BD1;&#x5668;&#x4F20;&#x5165;&#x4E00;&#x4E2A;&#x53EF;&#x9009;&#x7684;&#x6A21;&#x5757;&#x540D;&#xFF1A;</p>
<pre><code class="lang-TypeScript"><span class="hljs-comment">//// [amdModule.ts]</span>
<span class="hljs-comment">///&lt;amd-module name=&apos;NamedModule&apos;/&gt;</span>
<span class="hljs-keyword">export</span> <span class="hljs-keyword">class</span> C {
}
</code></pre>
<p>&#x7ED3;&#x679C;&#x4F1A;&#x628A;<code>NamedModule</code>&#x8D4B;&#x503C;&#x6210;&#x6A21;&#x5757;&#x540D;&#xFF0C;&#x505A;&#x4E3A;&#x8C03;&#x7528;AMD<code>define</code>&#x7684;&#x4E00;&#x90E8;&#x5206;&#xFF1A;</p>
<pre><code class="lang-JavaScript"><span class="hljs-comment">//// [amdModule.js]</span>
define(<span class="hljs-string">&quot;NamedModule&quot;</span>, [<span class="hljs-string">&quot;require&quot;</span>, <span class="hljs-string">&quot;exports&quot;</span>], <span class="hljs-function"><span class="hljs-keyword">function</span> (<span class="hljs-params">require, exports</span>) </span>{
    <span class="hljs-keyword">var</span> C = (<span class="hljs-function"><span class="hljs-keyword">function</span> (<span class="hljs-params"></span>) </span>{
        <span class="hljs-function"><span class="hljs-keyword">function</span> <span class="hljs-title">C</span>(<span class="hljs-params"></span>) </span>{
        }
        <span class="hljs-keyword">return</span> C;
    })();
    exports.C = C;
});
</code></pre>

                                
                                </section>
                            
    </div>
    <div class="search-results">
        <div class="has-results">
            
            <h1 class="search-results-title"><span class='search-results-count'></span> results matching "<span class='search-query'></span>"</h1>
            <ul class="search-results-list"></ul>
            
        </div>
        <div class="no-results">
            
            <h1 class="search-results-title">No results matching "<span class='search-query'></span>"</h1>
            
        </div>
    </div>
</div>

                        </div>
                    </div>
                
            </div>

            
                
                <a href="TypeScript 1.5.html" class="navigation navigation-prev " aria-label="Previous page: TypeScript 1.5">
                    <i class="fa fa-angle-left"></i>
                </a>
                
                
                <a href="TypeScript 1.3.html" class="navigation navigation-next " aria-label="Next page: TypeScript 1.3">
                    <i class="fa fa-angle-right"></i>
                </a>
                
            
        
    </div>

    <script>
        var gitbook = gitbook || [];
        gitbook.push(function() {
            gitbook.page.hasChanged({"page":{"title":"TypeScript 1.4","level":"1.7.17","depth":2,"next":{"title":"TypeScript 1.3","level":"1.7.18","depth":2,"path":"doc/release-notes/TypeScript 1.3.md","ref":"./doc/release-notes/TypeScript 1.3.md","articles":[]},"previous":{"title":"TypeScript 1.5","level":"1.7.16","depth":2,"path":"doc/release-notes/TypeScript 1.5.md","ref":"./doc/release-notes/TypeScript 1.5.md","articles":[]},"dir":"ltr"},"config":{"plugins":[],"styles":{"website":"styles/website.css","pdf":"styles/pdf.css","epub":"styles/epub.css","mobi":"styles/mobi.css","ebook":"styles/ebook.css","print":"styles/print.css"},"pluginsConfig":{"highlight":{},"search":{},"lunr":{"maxIndexSize":1000000,"ignoreSpecialCharacters":false},"sharing":{"facebook":true,"twitter":true,"google":false,"weibo":false,"instapaper":false,"vk":false,"all":["facebook","google","twitter","weibo","instapaper"]},"fontsettings":{"theme":"white","family":"sans","size":2},"theme-default":{"styles":{"website":"styles/website.css","pdf":"styles/pdf.css","epub":"styles/epub.css","mobi":"styles/mobi.css","ebook":"styles/ebook.css","print":"styles/print.css"},"showLevel":false}},"theme":"default","author":"Patrick Zhong","pdf":{"pageNumbers":true,"fontSize":12,"fontFamily":"Arial","paperSize":"a4","chapterMark":"pagebreak","pageBreaksBefore":"/","margin":{"right":62,"left":62,"top":56,"bottom":56}},"structure":{"langs":"LANGS.md","readme":"preface.md","glossary":"GLOSSARY.md","summary":"SUMMARY.md"},"variables":{},"title":"TypeScript Handbook","language":"zh-hans","gitbook":">3.0.0","description":"Translation of official TypeScript Handbook"},"file":{"path":"doc/release-notes/TypeScript 1.4.md","mtime":"2018-10-13T09:48:54.000Z","type":"markdown"},"gitbook":{"version":"3.2.3","time":"2018-10-13T09:57:42.904Z"},"basePath":"../..","book":{"language":""}});
        });
    </script>
</div>

        
    <script src="../../gitbook/gitbook.js"></script>
    <script src="../../gitbook/theme.js"></script>
    
        
        <script src="../../gitbook/gitbook-plugin-search/search-engine.js"></script>
        
    
        
        <script src="../../gitbook/gitbook-plugin-search/search.js"></script>
        
    
        
        <script src="../../gitbook/gitbook-plugin-lunr/lunr.min.js"></script>
        
    
        
        <script src="../../gitbook/gitbook-plugin-lunr/search-lunr.js"></script>
        
    
        
        <script src="../../gitbook/gitbook-plugin-sharing/buttons.js"></script>
        
    
        
        <script src="../../gitbook/gitbook-plugin-fontsettings/fontsettings.js"></script>
        
    

    </body>
</html>

